"""
弹出框分类：
	1）警告框（提示信息+确定按钮）  eg:警告提示密码长度不少于10
	2）确认框（提示信息+确定按钮+取消按钮）eg:是否删除
	3）提示框（输入框、确定、取消）
切换到弹出框：switch_to.alert
获取弹出框信息 .text
确认 accept
取消 dismiss
输入信息 send_keys()
"""

import time

from  selenium import webdriver
from  selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select

# 获取驱动
driver = webdriver.Edge()
# 通过驱动打开网页
driver.get("http://127.0.0.1/ranzhi/www")
time.sleep(1)

# 登录
driver.find_element("id","account").send_keys("admin")
driver.find_element("id","password").send_keys("123456")
driver.find_element("id","submit").click()
time.sleep(1)
# 点击文档
driver.find_element("id","s-menu-4").click()

# 切换到iframe
driver.switch_to.frame(driver.find_element("id","iframe-4"))
time.sleep(1)

#点击文档库
driver.find_element("class name","col-md-3").click()
time.sleep(1)
# 创建文档
driver.find_element("link text","创建文档").click()

# 选择文件
f = driver.find_element("name","files[]")
# 对文件的操作
# f.send_keys("d:\\a.txt")
f.send_keys("e:\\201-DevCpp-C++开发工具.zip")

# 切换到弹出框
alert1 = driver.switch_to.alert
# 获取弹出框内容
print(alert1.text)
# 点击确认
alert1.accept()

time.sleep(10)

# 切换到上一层
driver.switch_to.parent_frame()

# 签退
driver.find_element("link text","签退").click()
time.sleep(10)



